<?php

class Currency_model extends CI_Model{
	
	public function __construct(){
		parent::__construct();
	}
	
	function getCurrency(){
		$query = $this->db->query('select * from currency');
		if($query -> num_rows() > 0){
			foreach ($query -> result() as $rows){
				$data[] = $rows;	
			}	
			return $data;
		}	
	}

	function select($currency_id){
        return $this->db->get_where('currency', array('currency_id'=>$currency_id))->row();
    }
	
	function delete($currency_id){
		$this->db->delete('currency', array('currency_id'=>$currency_id));
	}
	
	function defaultCurrency(){
		$this->db->where('value', '1');
		$query = $this->db->get('currency');
			
		$row = $query->row_array();
		return $row['currency_id'];
	}
	
	function getSymbolLeft($currency_id){
		$this->db->where('currency_id', $currency_id);
		$query = $this->db->get('currency');
			
		$row = $query->row_array();
		return $row['symbol_left'];
	}
	
	function getSymbolRight($currency_id){
		$this->db->where('currency_id', $currency_id);
		$query = $this->db->get('currency');
			
		$row = $query->row_array();
		return $row['symbol_right'];
	}
	
	function getValue($currency){
		$query = $this->db->query('select value from currency where currency_id = "'.$currency.'"');
		if($query -> num_rows() > 0){
			foreach ($query -> result() as $rows){
				$data[] = $rows;	
			}	
			return $data;
		}
	}
	
	function getCode($currency_id){
		$this->db->where('currency_id', $currency_id);
		$query = $this->db->get('currency');
			
		$row = $query->row_array();
		return $row['code'];
	}
	
	function getStatus($currency){
		$query = $this->db->query('select status from currency where currency_id = "'.$currency.'"');
		if($query -> num_rows() > 0){
			foreach ($query -> result() as $rows){
				$data[] = $rows;	
			}	
			return $data;
		}
	}
	
	function product(){
		$query = $this->db->query('select price from product');
		if($query -> num_rows() > 0){
			foreach ($query -> result() as $rows){
				$data[] = $rows;	
			}	
			return $data;
		}	
	}
	
	function Currency($currency_id){
		$this->db->where('currency_id', $currency_id);
		$query = $this->db->get('currency');
			
		$row = $query->row_array();
		return $row['currency_id'];
	}
	
	function getId($currency_id){
		//$this->db->where('value', '1');
		$this->db->where('currency_id', $currency_id);
		$query = $this->db->get('currency');
			
		$row = $query->row_array();
		return $row['currency_id'];
	}
	
	
}

?>